package com.wyman.aop.framework;

import com.wyman.aop.AdvisedSupport;

/**
 * @Author 李伟民
 * @Description
 * @DateTime 2024/12/29 00:11
 */
public class ProxyFactory {

    private AdvisedSupport advisedSupport;
    public ProxyFactory(AdvisedSupport advisedSupport){
        this.advisedSupport = advisedSupport;
    }


    public Object getProxy(){
        return createProxy().getProxy();
    }


    public AopProxy createProxy(){
        if(advisedSupport.isProxyTargetClass()){
            return new Cglib2AopProxy(advisedSupport);
        }

        return new JdkDynamicAopProxy(advisedSupport);
    }
}
